home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0039_Getting BIG Drive Size.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  1KB  |  51 lines

  1. {
  2. BO BENDTSEN
  3.  
  4. Many people don't think about it, but DOS is limited to report more than
  5. 1 gigabyte. I have a 1.3 and a 1.0 gig, and made these routines for my
  6. programs for knowing if the drive size is more than 1 gig. Using the normal
  7. DiskSize and DiskFree could get you strange result, sometimes it could report
  8. maybe 100MB when it is really 1 gig.
  9.  
  10. If the size of free space is 1 you can assume that the drive is more than 1
  11. gigabyte.
  12. }
  13.  
  14. Function DriveSize(d : byte) : Longint; { -1 not found, 1=>1 Giga }
  15. Var
  16.   R : Registers;
  17. Begin
  18.   With R Do
  19.   Begin
  20.     ah := $36;
  21.     dl := d;
  22.     Intr($21, R);
  23.     If AX = $FFFF Then
  24.       DriveSize := -1 { Drive not found }
  25.     Else
  26.     If (DX = $FFFF) or (Longint(ax) * cx * dx = 1073725440) Then
  27.       DriveSize := 1
  28.     Else
  29.       DriveSize := Longint(ax) * cx * dx;
  30.   End;
  31. End;
  32.  
  33. Function DriveFree(d : byte) : Longint; { -1 not found, 1=>1 Giga }
  34. Var
  35.   R : Registers;
  36. Begin
  37.   With R Do
  38.   Begin
  39.     ah := $36;
  40.     dl := d;
  41.     Intr($21, R);
  42.     If AX = $FFFF Then
  43.     DriveFree := -1 { Drive not found }
  44.     Else
  45.     If (BX = $FFFF) or (Longint(ax) * bx * cx = 1073725440) Then
  46.       DriveFree := 1
  47.     Else
  48.       DriveFree := Longint(ax) * bx * cx;
  49.   End;
  50. End;
  51.